package com.zxcl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zxcl.dto.PageDTO;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zxcl.domain.SysLog;
import com.zxcl.mapper.SysLogMapper;
import com.zxcl.service.SysLogService;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;


@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService{


    @Override
    public Page<SysLog> loadSysLogPage(PageDTO pageDTO, SysLog sysLog) {
        Page<SysLog> page = new Page<>(pageDTO.getCurrent(),pageDTO.getSize());
        Page<SysLog> sysLogPage = getBaseMapper().selectPage(page, new LambdaQueryWrapper<SysLog>()
                .eq(!ObjectUtils.isEmpty(sysLog.getUserId()), SysLog::getUserId, sysLog.getUserId())
                .like(StringUtils.hasText(sysLog.getOperation()), SysLog::getOperation, sysLog.getOperation())
        );
        return sysLogPage;
    }
}
